#include "TNode.h"

	TNode::TNode() {};

	TNode::TNode(TYPE type, int index) {
		this->type = type;
		this->index = index;
	}

	void TNode::create(TYPE type, int index) {
		this->type = type;
		this->index = index;
	}

	TYPE TNode::getType() {
		return type;
	}

	vector<TNode> TNode::getChild() {
		return children;
	}

	void TNode::setChild(TNode child) {
		children.push_back(child);
	}

	TNode* TNode::getParent() {
		return parent;
	}

	void TNode::setParent(TNode parent) {
		this->parent = &parent;
	}

	int TNode::getIndex() {
		return index;
	}

	void TNode::setIndex(int index) {
		this->index = index;
	}

	bool TNode::isEqual(TNode node) {
		return true;
	}

	//root (type, index)
	//	child 1
	//		child of child 1
	//	child 2
	//		child 1 of child 2
	//		child 2 of child 1

	void TNode::toString() {
		cout << type << ", " << index;
		for ( int i = 0; i < children.size(); ++i ) {
			cout << "<";
			children.at(i).toString(1);
			cout << ">";
		}
	}

	void TNode::toString(int layer) {
		for ( int i = 0; i < layer; ++i ) {
			cout << "\t";
		}
		cout << type << ", " << index;
		for ( int i = 0; i < children.size(); ++i ) {
			cout << "<";
			children.at(i).toString(layer+1);
			cout << ">";;
		}
	}